<head>
    <title>添加测试用例</title>
    <link href="/lego/static/css/bootstrap.css" rel="stylesheet"/>
    <link href="/lego/static/css/header.css" rel="stylesheet"/>
    <link href="/lego/static/css/xcConfirm.css" rel="stylesheet"/>
    <link href="/lego/static/css/addTestCase.css" rel="stylesheet"/>
    <link href="/lego/static/css/jsonFormater.css" rel="stylesheet"/>
    <style>
        .jsonPathCheckPoint{
            width: 712px;
        }
    </style>
    <script src="/lego/static/js/jquery.1.11.3.min.js"/></script>
    <script src = "/lego/static/js/bootstrap.js" ></script>
    <script src="/lego/static/js/underscore-min.js"></script>
    <script src="/lego/static/js/common.js"></script>
    <script src="/lego/static/js/xcConfirm.js"></script>
    <script src="/lego/static/js/testCaseCommon.js"></script>
    <script src="/lego/static/js/jsonFormater.js"></script>
    <script type="text/javascript">
        $(function () {
            $.ajax({
                url: '/lego/getNextTestCaseId',
                type: 'GET',
                success: function (data) {
                    if (data && data.code == 200) {
                        $('#caseId').val(data.data);
                    }
                }
            });
        });
    </script>

</head>
<body style="background-color: rgb(248,248,248);">
    <#include "../navigationBar.ftl">
    <header class="jumbotron subhead" id="overview">
        <div class="container">
            <h1>测试用例维护</h1>
        </div>
    </header>

    <form method="post" class="form-horizontal" id="testCaseForm">
        <div class="testCaseDiv">
            <div class="row">
                <label for="projectId" class="col-sm-4 control-label">用例编号</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control " readonly="readonly" name="caseId" id="caseId">
                </div>
            </div>
            <div class="row">
                <label for="teamId" class="col-sm-4 control-label"><code>*</code>选择团队</label>
                <div class="col-sm-4" id="teamDiv"></div>
                <#include "../common/template.ftl">
            </div>
            <div class="row">
                <label for="projectName" class="col-sm-4 control-label"><code>*</code>选择项目</label>
                <div class="col-sm-4" id="projectDiv"></div>
            </div>
            <div class="row">
                <label for="url" class="col-sm-4 control-label"><code>*</code>url</label>
                <div class="col-sm-4" style="width:80px;padding-right:0px">
                    <select class="form-control" name="requestType" id="requestType">
                        <option value="GET">GET</option>
                        <option value="POST">POST</option>
                    </select>
                </div>
                <div class="col-sm-4" id="ipAndPort"></div>
                <div class="col-sm-4" style="padding:0px">
                    <input type="text" class="form-control" name="url" id="url">
                </div>
            </div>
        </div>
        <br>
        <div class="testCaseDiv">
            <div class="row">
                <label class="col-sm-4 control-label">header</label>
                <div class="col-sm-4">
                    <div class="col-sm-4" id="requestHeaderDiv">
                        <div style="width:635px;float:left;">请求头部</div>
                        <div class="glyphicon glyphicon-chevron-down" id="headerShowBtn">展开</div>
                        <input type="hidden" id="headerIndex" value="0"/>
                    </div>
                </div>
            </div>
            <div class="row" id="inputHeaderDiv" style="display: none;">
                <label class="col-sm-4 control-label"></label>
                <div class="col-sm-4">
                    <table class="table table-bordered" id="inputHeaderTable">
                        <tr>
                            <th style="text-align: center;width: 20%;">标签</th>
                            <th style="text-align: center;width: 70%">内容</th>
                            <th style="text-align: center;width: 10%">
                                <button class="btn btn-default addHeaderBtn" type="button">
                                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>ADD
                                </button>
                            </th>
                        </tr>
                        <tr>
                            <td><input type="text" class="form-control" name="headerKeys"></td>
                            <td><input type="text" class="form-control" name="headerValues"></td>
                            <td>
                                <button class="btn btn-default" type="button" onclick="deleteHeader(this)">
                                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>delete
                                </button>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <br>
        <div class="testCaseDiv" >
            <div id="paramsKVDiv" >
                <div class="row">
                    <label class="col-sm-4 control-label">params</label>
                    <div class="col-sm-4">
                        <div class="col-sm-4" id="paramsKVHeader">
                            <div style="width:635px;float:left;">请求参数</div>
                            <div class="glyphicon glyphicon-chevron-down" id="paramsShowBtn">展开</div>
                            <input type="hidden" id="paramsIndex" value="0"/>
                        </div>
                    </div>
                </div>
                <div class="row" style="display: none;" id="paramsKVBodyDiv">
                    <label class="col-sm-4 control-label"></label>
                    <div class="col-sm-4">
                        <table class="table table-bordered" id="inputParamsTable">
                            <tr>
                                <th style="text-align: center;width: 20%;">标签</th>
                                <th style="text-align: center;width: 70%">内容</th>
                                <th style="text-align: center;width: 10%">
                                    <button class="btn btn-default addParamsBtn" type="button">
                                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>ADD
                                    </button>
                                </th>
                            </tr>
                            <tr>
                                <td><input type="text" class="form-control" name="paramKeys"></td>
                                <td><input type="text" class="form-control" name="paramValues"></td>
                                <td>
                                    <button class="btn btn-default" type="button" onclick="deleteHeader(this)">
                                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>delete
                                    </button>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
            <div class="row" id="paramsRawDiv" style="display: none;">
                <label class="col-sm-4 control-label">params</label>
                <div class="col-sm-4">
                    <textarea type="text" class="form-control" name="paramRaw"></textarea>
                </div>
            </div>
        </div>
        <br/>
        <div class="testCaseDiv">
            <div class="row">
                <label for="jsonPathCheckPoint" class="col-sm-4 control-label">JsonPath检查点<br/>(多检查点使用<code>&&</code>分割)</label>
                <div class="col-sm-4">
                    <textarea type="text" class="form-control jsonPathCheckPoint" name="jsonPathCheckPoint" rows="5px"></textarea>
                </div>
            </div>
        </div>

        <div class="text-center" style="margin-top: 15px">
            <button class="btn btn-success" type="button" id="addTestCaseBtn">
                <span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存
            </button>
            <button class="btn btn-info executeTestCaseBtn" type="button">
                <span class="glyphicon glyphicon-play" aria-hidden="true"></span>执行
            </button>
            <a class="btn btn-primary" href="/lego/testCaseListIndex">
                <span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span>返回列表
            </a>
        </div>
        <br/>
        <div class="testCaseDiv executeResultTitle" style="display: none;padding:10px;font-weight:bold;">执行结果</div>
        <div class="testCaseDiv executeResult" style="display: none"></div>
    </form>
</body>
